import { useStorage } from '@/utils/storeage';

//#ifndef H5
import { siteinfo } from "@/siteinfo";
const isH5=false
// #endif

// #ifdef H5
const isH5=true
// #endif

const host = () => {
	// #ifndef H5
	return siteinfo.siteroot;
	// #endif

	// #ifdef H5
	let baseURL = 'https://xcyd.kf.kaifa.cc';
	if(process.env.NODE_ENV !== 'development' ){
		 baseURL = globalThis.location.origin + globalThis.location.pathname;
		if (baseURL.endsWith("//")) {
			baseURL = baseURL.replace(/\/\/$/, "/");
		}
	}
	return baseURL;
	// #endif
};

const appid = () => {
	// #ifndef H5
	return siteinfo.app_id;
	// #endif
	// #ifdef H5
	return useStorage().get('APPID');
	// #endif
};

const developmentUrl = `${host()}/app/ycTopic/api/`;

const productionUrl = `${host()}/app/ycTopic/api/`;

const baseUrl = process.env.NODE_ENV === 'development' ? developmentUrl : productionUrl;


export default {
	baseUrl,
	appid,
	isH5
};